package API.Collection.Set.TreeSet.Arrange.ListString;

import java.util.Comparator;
import java.util.Set;
import java.util.TreeSet;

public class ListString {
    public static void main(String[] args) {
        Set<String> set = new TreeSet<>((o1, o2) -> {
                int i = o1.length() - o2.length();
                return i == 0 ? o1.compareTo(o2) : i;

        });
        set.add("g");
        set.add("abc");
        set.add("def");
        for (String s : set) {
            System.out.println(s);
        }
    }
}
